<style type="text/css">
    #preview img{padding-bottom: 0} 
    #preview{padding:5px 6px}
    /*    .ui-tooltip{
            width:400px
        }
        .ui-tooltip-content{
            font-weight: normal;
        }*/
    #google_map{
        width:100%
    }
</style>

<script type="text/javascript">

    // Javascript popup windows
    function popup_cancel(url, w, h) {
        newWindow = window.open(url, 'popupWindow', 'width=' + w + ',height=' + h + ',menubar=no,toolbar=no,location=no,bookmarks=no,status=no,scrollbars=yes,resizable=yes');
        if (window.focus) {
            newWindow.focus();
        }
    }

</script>

<script>
    var d = '<?= (isset($object->availability) && count($object->availability)) > 0 ? json_encode($object->availability) : 0; ?>';
    var m = '<?= count($googlemap) > 0 ? json_encode($googlemap) : 0; ?>';
    var preview = '<?= isset($_GET['preview']) ? 1 : 0; ?>';
</script>

<div class="clearfix">

    <div class="hotels-list hotel-details">

        <? if (!isset($_GET['preview']) > 0 && !isset($object->NOT_AVAILABLE)): ?>

        <!--                <div class="top-book-now">
                            <a href="#go_to_rooms" class="btn btn-primary"><?= lang('hotel.book_now') ?></a>
                        </div>-->

        <? endif; ?>

        <!--        <div class="clearfix">
        
                    <div class="breadcrumb clearfix">
                        <div class="left"><a href="javascript:" class="search_term"><?= lang('hotell.search_term') ?>:</a></div>
                        <div class="left">&nbsp;&nbsp;</div>
                        <div class="left active">"<? if (isset($_GET['dest_hot'])) echo $_GET['dest_hot']; ?>"</div>
                    </div>
        
                </div>-->

        <div class="hotel-top-wrap">

            <div class="review_float" style=" padding: 11px 0 3px">

                <?php if ($object->avg_reviews_score != 0): ?>

                <div class="big_review_score"> 

                    <?= lang((string) number_format($object->avg_reviews_score, 1)) ?>,  <?= (string) number_format($object->avg_reviews_score, 1); ?>

                </div>

                <a href="javascript:" class="view_all_reviews"><?= lang('hotel.see_reviews') ?></a>


                <?php endif; ?>


            </div>


            <h1><?= $object->object_name; ?>
                <? if ($object->object_number_of_stars != ""): ?>
                <span class="hotel-star star_<?= $object->object_number_of_stars ?>" title="<?= $object->object_number_of_stars ?> stars hotel">&nbsp;</span>
                <? endif; ?>
            </h1>

            <p class="address"><?= $object->object_address; ?>
                <?
                if (isset($object->object_x_coordinate) && $object->object_x_coordinate != ""):
                if (isset($object->object_y_coordinate) && $object->object_y_coordinate != ""):
                ?>

                <a data-id="<?= $object->object_ID; ?> ?>" title="<?= $object->object_name; ?>, <?= $object->destination_name; ?> - <?= lang('hotel.show_map_cap') ?>" class="show_map" href="javascript:"><?= lang('hotel.show_map_cap') ?></a>
                <?
                endif;
                ?>
                <? endif; ?>
                <? if (isset($object->object_smart_deal) && $object->object_smart_deal != ""): ?>
            <span class="smart-deal">Recommended</span>
            <? endif; ?>
            </p>
        </div>

        <div class="hotel-reviews" id="hotel-reviews" style="display:none">
            <? $this->load->view('booking/reviews') ?>
        </div>

        <div id="swich_hotel_content">

            <div class="pikachoose">

                <ul id="pikame" class="jcarousel-skin-pika">

                    <?php
                        foreach ($object->photos as $photo):

                        $thumbnail = HOST_URL . $photo->path . '/thumb_709x403/' . $photo->photo_name;
                    ?>    

                    <li><img src="<?= $thumbnail ?>" alt="<?= $photo->photo_title ?>" style="display: none"></li>
                    <?php endforeach; ?>

                </ul><!-- Main Pica Gallery -->

            </div>

            <!-- TODO ovdje ubaciti ikonice za wifi i sl -->

            <div class="iconset-1">
                <!-- OK -->    <? if (isset($object->object_wireless_communication)): ?><div class="wifi"></div><? endif; ?>
                <!-- OK -->    <? if (isset($object->object_internet) || isset($object->object_internet_caffe) || isset($object->object_internet_connection)): ?><div class="internet"></div><? endif; ?>
                <!-- OK -->    <? if (isset($object->object_indoor_pool) || isset($object->object_outdoor_pool) || isset($object->object_childrens_pool)): ?><div class="pool"></div><? endif; ?>
                <!-- OK -->    <? if (isset($object->object_pets_are_alowed)): ?><div class="pets"></div><? endif; ?>
                <!-- OK -->    <? if (isset($object->object_hotel_parking) || isset($object->object_public_parking)): ?><div class="parking"></div><? endif; ?>
            </div>

            <div class="hotel-details" id="hotel-details" style="display:block">

                <div class="object_info"><?= $object->object_info ?> </div>

                <? if (!isset($_GET['preview']) > 0 && !isset($object->NOT_AVAILABLE)): ?>

                <div class="nr_units"><p><?= lang('hotel.rooms') ?>: <?= count($object->rooms) ?></p></div>

                <? endif; ?>

                <!-- Availability -->

                <h3><span class="normal"><?= lang('hotel.availability') ?></span></h3>

                <? if (isset($_GET['preview']) > 0 || isset($object->NOT_AVAILABLE)): ?>

                <?
                if (isset($object->NOT_AVAILABLE)) {
                ?>
                <br/>
                <div class="available_info">

                    <span class="exclamation">&nbsp;!&nbsp;</span>
                    <div class="not-available"><?= lang('hotel.not_available') ?></div>

                </div>

                <script type="text/javascript">
                    var is_post_room_search = true;
                </script>

                <? } ?>

                <?
                $obj_name = URLify::filter($object->object_name);
                $href = base_url('accommodation/' . $obj_name . '-' . $object->object_ID);
                ?>


                <form method="get" action="<?= $href ?>">

                    <?php
                        /*
                         * Destination
                         */
                        $dest_hot = lang('search.search_placeholder');

                        if (isset($_GET['dest_hot']) && ($_GET['dest_hot'] != -1 ) && ($_GET['dest_hot'] != "" ))
                        $dest_hot = $_GET['dest_hot'];

                        /*
                         * Checkin, Checkout
                         */
                        $check_in = date('d.m.Y', strtotime("+1 day"));

                        if (isset($_GET['check_in']))
                        $check_in = $_GET['check_in'];

                        $check_out = date('d.m.Y', strtotime("+2 day"));

                        if (isset($_GET['check_out']))
                        $check_out = $_GET['check_out'];

                        //    $this->firephp->log($check_in);
                        //    $this->firephp->log($check_out);

                        /*
                         * Number persons
                         */
                        $sel_text = 'selected = "selected"';

                        if (isset($_GET['nr_adults'])) {
                        $selected = $_GET['nr_adults'];
                        $cnt = 5;
                        } else {
                        $selected = 2;
                        $cnt = 5;
                        }

                        if (isset($_GET['nr_childrens'])) {
                        $selected_CH = $_GET['nr_childrens'];
                        $cnt_CH = 5;
                        } else {
                        $selected_CH = 0;
                        $cnt_CH = 5;
                        }
                    ?>


                    <!-- ADDED DURING CYRRENCY UPGRADE -->
                    <? if (isset($_GET['currency'])): ?>
                    <input type="hidden" name="currency" value="<? echo($_GET['currency']) ?>"></input>
                    <? endif; ?>
                    <!-- END ADDED -->

                    <input type="hidden" name="hotel_id" value="<?= $object->object_ID ?>" />
                    <input type="hidden" name="room_id" value="<?= $object->rooms[0]->room_ID ?>" />
                    <input type="hidden" name="is_post_room_search" value="1" />

                    <div class="form-vertical form-col top-10 clearfix available_form">

                        <div class="col">
                            <label><?= lang('hotel.check_in') ?></label>
                            <input type="text" name="check_in" id="ckeck_in2" value="<?= $check_in ?>" class="checkinout"/>
                        </div>

                        <div class="col">
                            <label><?= lang('hotel.check_out') ?></label>
                            <input type="text" name="check_out" id="check_out2" value="<?= $check_out ?>" class="checkinout"/>
                        </div>

                        <div class="col clearfix">

                            <label><?= lang('hotel.adults') ?></label>

                            <select name="nr_adults" id="nr_adults2" class="dropdownized">
                                <? for ($index = 1; $index <= $cnt; $index++): ?>
                                <option value = "<?= $index ?>" <? if ($selected == $index) echo $sel_text; ?>><?= $index ?></option>
                                <? endfor; ?>
                            </select>

                        </div>

                        <div class="col clearfix">

                            <label><?= lang('hotel.children') ?></label>

                            <select name="nr_childrens" id="nr_childrens2" class="dropdownized">
                                <? for ($index = 0; $index <= $cnt_CH; $index++): ?>
                                <option value = "<?= $index ?>" <? if ($selected_CH == $index) echo $sel_text; ?>><?= $index ?></option>
                                <? endfor; ?>
                            </select>

                        </div>

                        <div class="col clearfix ages2" <? if (isset($_GET['nr_childrens']) && $_GET['nr_childrens'] != 0) echo 'style="display:block"'; ?>>

                             <label><?= lang('hotel.age') ?></label>

                            <div class="left mr10 age-1"><input type="text" name="ages[]" class="positive-integer" value="<? if (isset($_GET['ages'][0])) echo $_GET['ages'][0]; ?>" /></div>  
                            <div class="left mr10 age-2"><input type="text" name="ages[]" class="positive-integer" value="<? if (isset($_GET['ages'][1])) echo $_GET['ages'][1]; ?>" /></div>  
                            <div class="left mr10 age-3"><input type="text" name="ages[]" class="positive-integer" value="<? if (isset($_GET['ages'][2])) echo $_GET['ages'][2]; ?>" /></div>  
                            <div class="left mr10 age-4"><input type="text" name="ages[]" class="positive-integer" value="<? if (isset($_GET['ages'][3])) echo $_GET['ages'][3]; ?>" /></div>  
                            <div class="left mr10 age-5"><input type="text" name="ages[]" class="positive-integer" value="<? if (isset($_GET['ages'][4])) echo $_GET['ages'][4]; ?>" /></div>   

                        </div>

                        <div class="col" style="margin-top:-2px !important">
                            <div class="form-actions top-10 right"><button class="btn"><?= lang('hotel.check_availability') ?></button></div>
                        </div>


                    </div>

                </form>

                <br/>

                <? endif; ?>

                <!-- HOTEL ROOMS -->

                <?php if (!isset($_GET['preview']) > 0 &&!isset($object->NOT_AVAILABLE)): ?>



                <table  id="go_to_rooms" cellpadding="0" cellspacing="0">

                    <tbody>

                        <?php foreach ($object->rooms as $room): ?>

                        <tr>
                            <td class="clearfix">

                                <div class="photo">

                                    <?php
                                        $room_type_name = str_replace("-", "_", underscore($room->room_type_name));
                                        $room_type_name = lang('room.' . $room_type_name);

                                        if (isset($room->photos[0])):
//                                        $this->firephp->log($object);
//                                        $this->firephp->log($room);
                                        $preview = $host_url . $object->photo_path . '/rooms/' . $room->photos[0]->path . '/thumb_454x340/' . $room->photos[0]->photo_name;
                                        $thumbnail = $host_url . $object->photo_path . '/rooms/' . $room->photos[0]->path . '/thumb_70x70/' . $room->photos[0]->photo_name;
                                    ?>

                                    <a href="<?= $preview ?>" class="preview" title="<?= $room_type_name ?>" onClick="return false;">

                                        <img src="<?= $thumbnail ?>" alt="<?= $object->object_name; ?>" />

                                    </a>

                                    <?php endif; ?>
                                </div>

                                <div class="holder">

                                    <div class="title tooltip" title="<b><?=
                                        $room_type_name;
                                        if ($room->room_description != "")
                                        echo " " . $room->room_description;
                                    ?></b>"><?=
                                                 $room_type_name;
                                                 if ($room->room_description != "")
                                                 echo " " . $room->room_description;
                                             ?></div>

                                    <div class="info"> <?= $room->service_name ?></div>

                                    <div class="cancelation tooltip" title="<?= $room->room_cancellation ?>"></div>

                                    <?php if ($room->room_units_left == 1): ?>

                                    <div class="units_left_wrap">

                                        <span class="units_left tooltip" title="Only <?= $room->room_available_units ?> left for <?= $room->selling_total ?> <?= currency_sign() ?> <?= lang('hotel.more_available') ?>">
                                            Only <?= $room->room_available_units ?> left
                                        </span>

                                    </div>

                                    <?php endif; ?>

                                    <?php if (isset($room->room_info)): ?>

                                    <p class="info">
                                        <?php
                                            $str = clean_html($room->room_info);

                                            if ($room->room_units_left == 1) {
                                            $lng = 60;
                                            } else {
                                            $lng = 80;
                                            }

                                            if (mb_strlen($str) > $lng) {
                                            $str = mb_substr($str, 0, $lng) . ' <span class="tooltip read_room" title="' . $room->room_info . '">»</span>';
                                            }
                                            echo $str;
                                        ?>
                                    </p>

                                    <?php endif; ?>


                                    <? if ($room->room_free_storno == 1): ?>

                                    <div class="info"> • <span class="green"><?= lang('hotel.free_cancel') ?></span> </div>

                                    <? endif; ?>
                                    <div class="clearfix">
                                        <div class="left tooltip max_ps ps_<?= $room->room_max_person ?>"></div> <div class="left max_ps_txt"><?= lang('hotell.max_persons') ?>: <?= $room->room_max_person ?></div>
                                    </div>

                                </div>

                            </td>

                            <td>
                                <div <? if (isset($_GET['currency'])) if ($_GET['currency'] == 'RUB') echo('style = "font-size: 16px"') ?> class="price"><?= $room->selling_total ?> <?= currency_sign() ?></div>

                                <div class="relative">
                                    <?php
                                        $_myGet = $_GET;
                                        if (isset($_myGet['room_id']))
                                        unset($_myGet['room_id']);
                                        if (isset($_myGet['lang']))
                                        unset($_myGet['lang']);
                                        if (isset($_myGet['is_post_room_search']))
                                        unset($_myGet['is_post_room_search']);
                                        if (isset($_myGet['dest_hot']))
                                        unset($_myGet['dest_hot']);
                                    ?>
                                    <a href="<?= SECU_URL . $this->lang->lang() . "/?room_id=" . $room->room_ID . "&" . http_build_query($_myGet) ?>" <?php
                                        $lng = $this->lang->lang();
                                        if ($lng == 'ru')
                                        echo('style=font-size:9px');
                                        elseif ($lng == 'de')
                                        echo('style=font-size:10px');
                                    ?> class="btn"><?= lang('hotel.book_now') ?></a>

                                </div>

                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>

                <? endif; ?>

                <h3><?= lang('hotel.facilities') ?> <span class="normal"> <?= lang('hotel.of') ?> <?= $object->object_name; ?></span></h3>

                <div class="facility_wrap x_facilities">
                    <?php $this->load->view('parts/facilities') ?>

                </div>

                <h3><?= lang('hotel.polices') ?> <span class="normal"><?= lang('hotel.of') ?> <?= $object->object_name; ?></span></h3>

                <div class="facility_wrap">

                    <? foreach ($object->polices as $policy => $val): ?>

                    <div class="one_facility clearfix">

                        <span class="title"><?= $policy ?>: </span><span class="text"><?= $val ?></span>

                    </div>

                    <? endforeach; ?>
                    <? if ($object->object_cancellation != ""): ?>
                    <div class="one_facility clearfix">
                        <span class="title"><?= lang('hotel.cancelation') ?>: </span><span class="text"><?= clean_html($object->object_cancellation) ?></span>
                    </div>
                    <? endif; ?>

                    <? if ($object->object_extra_bed != ""): ?>
                    <div class="one_facility clearfix">

                        <span class="title"><?= lang('hotel.extra_bed') ?>: </span><span class="text"><?= clean_html($object->object_extra_bed) ?></span>
                    </div>
                    <? endif; ?>

                </div>

                <br/>
                <br/>

            </div>

            <div class="we_guarantee_wrap">
<!--                <div><?= lang('hotel.we_guarantee') ?></div>
                <ol>
                    <li><span><?= lang('hotel.wg1t') ?></span> <?= lang('hotel.wg1v') ?></li>
                    <li><span><?= lang('hotel.wg2t') ?></span> <?= lang('hotel.wg2v') ?></li>
                    <li><span><?= lang('hotel.wg3t') ?></span> <?= lang('hotel.wg3v') ?></li>
                    <li><span><?= lang('hotel.wg4t') ?></span> <?= lang('hotel.wg4v') ?></li>
                </ol>-->
                <span class="tos"><?= lang('hotel.terms_info_text') ?> <a onclick="popup_cancel(this.href, 400, 390);
                        return false;" href="<?= base_url('terms_and_conditions?hotel_id= ' . $_GET['hotel_id']) ?>"><?= lang('hotel.booking_conditions') ?></a> <?= lang('hotel.terms_and') ?> <a onclick="popup_cancel(this.href, 600, 490);
                                return false;" href="<?= base_url('general_terms') ?>"><?= lang('hotel.general_terms') ?></a>.</span>


            </div>

        </div>

    </div>

    <div class="details search-details">
        <? //$this->load->view('booking/search-details')        ?>
        <? $this->load->view('booking/search-box') ?>

        <div style="clear:both"></div>
        <script type="text/javascript">

            var LOADMAP = false;

        </script>

        <?
        if (isset($object->object_x_coordinate) && $object->object_x_coordinate != ""):
        if (isset($object->object_y_coordinate) && $object->object_y_coordinate != ""):
        ?>
        <div class="side-google-map googlebox" style="background-image: url('http://maps.googleapis.com/maps/api/staticmap?key=AIzaSyACIkfLKjw2w9u2V9XKJUqnFqfIirp6Bsc&sensor=false&size=250x205&center=<?= $object->object_x_coordinate ?>,<?= $object->object_y_coordinate ?>&zoom=14');"> <!-- GOOGLE MAP PREVIEW GOES HERE  -->
            <div class="action"><a href="javascript:" data-id="<?= $object->object_ID ?>" class="btn googlebox show_map"><?= lang('hotel.show_map_cap') ?></a></div>
            <!--<img src="<?= base_url() ?>assets/img/google/bed-icon-active.png" alt="<?= $object->object_name ?>" />-->
        </div>
        <script type="text/javascript">

//            var LOADMAP = true;

        </script>

        <?
        endif;
        endif;
        ?>

    </div>

</div>

<div id="google_box" style="">
    <div class="clearfix">

        <div id="google_map">
            <div id="map_canvas" style="width:100%; height:100%"></div>
        </div>

    </div>

</div>


<script type="text/javascript">

    var do_gallery = false;
<?php if (count($object->photos) > 1): ?>
    do_gallery = true;
<?php endif; ?>
    var do_form2 = true;

    var nr_children2 = 0;
<?php
    if (isset($_GET['nr_childrens'])):
?>
    nr_children2 = '<?= $_GET['nr_childrens'] ?>';
<?php endif; ?>

</script>